package cn.fengzhilun.javase.day13;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.junit.Test;

public class TestMap {
	private final static Map<Integer,String> WEEK_DAY_NAMES=new HashMap<>();
	static {
		WEEK_DAY_NAMES.put(1, "星期一");
		WEEK_DAY_NAMES.put(2, "星期二");
		WEEK_DAY_NAMES.put(3, "星期三");
		WEEK_DAY_NAMES.put(4, "星期四");
		WEEK_DAY_NAMES.put(5, "星期五");
		WEEK_DAY_NAMES.put(6, "星期六");
		WEEK_DAY_NAMES.put(7, "星期天");
	}
	@Test
	public void test() {
		assertEquals("星期一", getWeekDayName(1));
		assertEquals("星期天",getWeekDayName(7));
		assertNull(getWeekDayName(8));
		
	}
	
	public static String getWeekDayName(int num) {
//		if(num>7||num<1){
//			return null;
//		}
//		
//		String [] array= {"星期一","星期二","星期三","星期四"
//				,"星期五","星期六","星期天"};
//		return array[num-1];
//		Map<Integer,String> map =new HashMap();
//		map.put(1, "星期一");
//		map.put(2, "星期二");
//		map.put(3, "星期三");
//		map.put(4, "星期四");
//		map.put(5, "星期五");
//		map.put(6, "星期六");
//		map.put(7, "星期天");
		
		//return map.get(num);
		return WEEK_DAY_NAMES.get(num);
	}
	
	@Test
	public void test1() {
		Map<Integer,String> map =new HashMap<>();
		map.put(1, "星期一");
		map.put(2, "星期二");
		map.put(7, "星期天");
		for(Entry<Integer, String> entry:map.entrySet()) {
			System.out.println("key:"+entry.getKey()+"value:"+entry.getValue());
		}
		for(Integer i: map.keySet()) {
			System.out.println("key:"+i+"value:"+map.get(i));
		}
		System.out.println(map.get(7));
	}
	@Test
	public void test2() throws IOException {
		List<String> lines = Files.readAllLines(Paths.get("data/scores.csv"));
		
		Map<String,String> stat=new HashMap<>();
		//Map<String,String> stat1=new HashMap<>();

		for(String line:lines) {
			//System.out.println(line);
			String[] split = line.split(",");
			for(String word: split) {
				//System.out.println(word);
				stat.put((split[0]+split[1]), split[2]);
			}
			
			System.out.println(stat);
//			for(int i=0;i<split.length;i++) {
//				if(i+2<split.length) {
//					String s+=split[i];
//					//stat.put(split[i], split[i+1]);
//					//stat1.put(split[i+1], split[i+2]);
//					System.out.println(split[i]);
//				}
//			
				
//			}
		}
		//stat.get("张三")
	}
//	public static int getScores(String name ,String atClass) {
//		
//	}
}
